// 防抖
export const debounce = (callback, interval = 1000 / 60) => {
  let timeOut
  return function (...args) {
    timeOut && clearTimeout(timeOut)
    timeOut = setTimeout(() => {
      window.requestAnimationFrame(() => {
        callback.apply(this, args)
      })
    }, interval)
  }
}

//节流
export const throttle = (callback, interval = 1000 / 60) => {
  let pre = 0
  return function (...args) {
    let now = Date.now()
    if (now - pre > interval) {
      window.requestAnimationFrame(() => {
        pre = now
        callback.apply(this, args)
      })
    }
  }
}
